package com.icinfo.cloud.provider.punish.ucase.casemain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 描述：修改类别
 * @author shishengyao
 * @description
 * @date 2023/2/22
 */
@AllArgsConstructor
public enum ShowEditButtonTypeEnum {
    /**
     * 是否允许修改的类别  0:不允许 1:允许修改 2：重制文书 3:补正/更正 4:简案快办编辑
     */
    NOT_EDIT("0", "不允许修改"),
    ALLOW_EDIT("1", "修改"),
    ALLOW_REMAKE("2", "重制"),
    ALLOW_CORRECTION("3", "补正/更正"),
    ALLOW_EDIT_FAST_CASE("4", "编辑");

    /**
     * 编码
     */
    @Getter
    private String code;
    /**
     * 描述
     */
    @Getter
    private String des;

    /**
     * 描述：根据code获取value
     *
     * @param code 编码
     * @return 描述内容
     * @author xiangyuyu
     * @date 2022-02-22 10:43
     */
    public static String getValueByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (ShowEditButtonTypeEnum e : ShowEditButtonTypeEnum.values()) {
            if (code.equals(e.getCode())) {
                return e.getDes();
            }
        }
        return null;
    }



    /**
     * 描述：校验code是否是合法枚举
     *
     * @param code 枚举code
     * @return boolean 是否合法枚举（true-是/false-否）
     * @author xiangyuyu
     * @date 2022-02-22 10:42
     */
    public static boolean isLegalEnumCode(String code) {
        boolean flag = false;
        for (ShowEditButtonTypeEnum e : ShowEditButtonTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}
